var app = getApp()
var gb = app.globalData
var Bmob = gb.Bmob
var SessionMgr = gb.SessionMgr

var Define = require("../../lib/Define.js")

var _sessionUser = null

Page({
  data:{
    user:{
      avatarUrl:"/images/theme_d/icon_2.png",
      nickName:"请登录"
    }
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示

    var self = this

    _sessionUser = Define.getStoredUserInfo()
    if (_sessionUser) {
      self.setData({ user: _sessionUser })
    }
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },
  onUserClick:function(){
    var self = this
    if(_sessionUser){

    }else{
      wx.navigateTo({
        url: '../setphone/setphone'
      })
    }
  },
  onAboutUsClick:function(){
    wx.navigateTo({
      url: '/pages/aboutus/aboutus',
    })
  },
  onOrderCellClick:function(){

    if(!_sessionUser){
      return
    }

    wx.navigateTo({
      url: '/pages/user/order/order'
    })
  },
  onPhoneClick:function(){
    Define.callServicePhone()
  },
  onMapnavButtonClick:function(){
    wx.openLocation({
      latitude: '31.133128',
      longitude: '104.176187',
      fail:function(err){
        console.log(err)
      }
    })
  }
})